



import bpy
from bpy.types import Operator
from 全局控制.Node.节点和插座基类.bl_UpdateNode import *
from 全局控制.Node.节点和插座基类 import bl_容器节点 as 容器

import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类
import 全局控制.Node.插座.bl_插座基类 as 插件基类
#import 全局控制.Node.节点和插座基类.bl_UpdateNode as 节点插座查找

import Core.bl_UI配色 as UI配色

import engine.initLIB.load_dll as engineLib
import ctypes





engineLib.flexCAPI.f_创建判断节点.restype = ctypes.c_bool




E_类型枚举 = [
	("TYPE_加法", "+", "", 0),
	("TYPE_减法", "-", "", 1),
	("TYPE_乘法", "*", "", 2),
	("TYPE_除法", "/", "", 3),
	("TYPE_取余", "%", "", 4),

	("TYPE_取反", "！", "", 5),
	("TYPE_左移", "<<", "", 6),
	("TYPE_右移", ">>", "", 7),

	("TYPE_按位与", "&", "&", 8),
	("TYPE_按位或", "|", "|", 9),
	("TYPE_按异或", "^", "^", 10),
]



class C_Node_判断(基类.C_Node_基类):
	bl_dname = 'bl_node_判断'
	bl_label = '判断'
	
	def init(self, context):
		super(C_Node_判断, self).f_init(context)
		self.inputs.new('C_Socket_I8_Array1D', name='条件')
		self.outputs.new('C_Socket_I8_Array1D', name='真')
		self.outputs.new('C_Socket_I8_Array1D', name='假')

		self.f_toCPP()

		self.use_custom_color = True
		self.color = UI配色.g_内部节点颜色

	def draw_label(self):
		return 'if'
	
	def f_toCPP(self):
		是否更新 = engineLib.flexCAPI.f_创建判断节点(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), self.f_getPyObject());
		if 是否更新 :
			self.inputs['条件'].f_update()


class C_NODE_AddMenu_判断(bpy.types.Operator):
	bl_idname = 'node.global_node_if'
	bl_label = 'if'
	bl_options = {'REGISTER', 'UNDO'}
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_判断', use_transform=True)
		return {'FINISHED'}



classes = (
	C_Node_判断,
	C_NODE_AddMenu_判断,
	
)




def register():
	for c in classes:
		bpy.utils.register_class(c)
		
	
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)

	

